package ThreadDemo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2025-03-20
 * Time: 22:14
 */
public class ThreadDemo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(
                ()->{
                    for (int i = 0; i < 5; i++) {
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
        );
        //线程启动之前，状态是NEW
        System.out.println(t.getState());
        t.start();
        t.join();//先执行线程t，最后执行main线程
        //线程结束之后，状态是TERMINATED
        System.out.println(t.getState());
    }
}
